#ifndef LOGDLG_P_H
#define LOGDLG_P_H

#include <QObject>
#include <QSet>
#include <QCalendarWidget>
#include <QTextTableFormat>

namespace DataLogger
{
class LogDlg;

class CustomCalendar : public QCalendarWidget
{
public:
    CustomCalendar(QWidget *parent);

    void insertDate(const QDate &validDate);
    void clearDateSet();

protected:
    void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const;

private:
    QSet<QString> dateSet;
};

class LogDlgPrivate : public QObject
{
    Q_OBJECT

public:
    LogDlgPrivate(LogDlg *parent);
    ~LogDlgPrivate();

    void initializeMember();
    void connectSignalsAndSlots();
    void completeConstruct();

private slots:
    void updateLogData();
    void updateDate();

private:
    void appendMessage(const QString &from, const QString &time, const QVariant &message);

    inline void updatePrivateLogData(const QString &clientName, const QDate &date);
    inline void updatePublicLogData(const QDate &date);
    void updateLogDataBySql(const QString &queryLogDataSql);

    inline void updatePrivateDate(const QString &clientName);
    inline void updatePublicDate();
    void updateDateBySql(const QString &queryValidDateSql);

private:
    LogDlg * const q;
    QTextTableFormat tableFormat;
    CustomCalendar *calendar;
};
}
#endif // LOGDLG_P_H
